faApp.controller('OrderManagerUserListCtrl',['$scope','orderManagerService','$location','$controller','$route',function($scope,orderManagerService,$location,$controller,$route) {   
  $controller('BaseListCtrl', {$scope: $scope}); 

  $scope.orderManagerUserList = [];
  $scope.loading = true;

  $scope.$watch('config',function(){
    if ($scope.watchIsChange()){
      orderManagerService.list($scope.config).then(function(json){
        if (json.statusCode){
          alert("出错了:" + json.statusCode);
        }else{
          $scope.orderManagerUserList = json.list;
          $scope.pager = json.page;
          $scope.loading = false;
        }
      });
    }
  },true);  

  $scope.config = {
    "pageSize" : 20,
    "pageNo" : 1
  };

  $scope.editManagerOrderByUser = function(uid){
    if(uid != undefined){
      if(confirm("确认要回收所有订单权限吗？")){
        orderManagerService.editManagerOrderByUser(uid).then(function(json){
          if (json.statusCode){
            alert("出错了:" + json.statusCode);
          }else{
            alert("回收成功！");
          }
        });
      }
    }
  }
}]);

faApp.controller('OrderManagerUserAddCtrl',['$scope','orderManagerService','$location','$controller','$route',function($scope,orderManagerService,$location,$controller,$route) {   
  $controller('BaseListCtrl', {$scope: $scope}); 

  $scope.userNotManager = {};
  $scope.notOrderManagerUserList = [];

  orderManagerService.notOrderManagerUserList().then(function(json){
    if (json.statusCode){
      alert("出错了:" + json.statusCode);
    }else{
      $scope.notOrderManagerUserList = json.list;
    }
  });

  $scope.save = function(){
    if (!$scope.form.$invalid){
      orderManagerService.orderManagerUserAdd($scope.userNotManager).then(function(json){
        if (json.statusCode){
          alert("出错了:" + json.statusCode);
        }else{
          $scope.alertNextPage("添加成功！");
          $route.reload();
        }
      });
    }else{
      alert("请选择人员！");
    }
  }

}]);